package com.scut.campus.controller;


import com.scut.campus.response.Result;
import com.scut.campus.utils.AliOSSUtils;
import com.scut.campus.utils.ModelUtil;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@Tag(name = "大模型调用功能")
@RequestMapping("/model")
@Slf4j
@RestController
public class ModelController {
    @Autowired
    private AliOSSUtils aliOSSUtils;

    @Autowired
     private ModelUtil modelUtil;




    private static String PROPMT="用中文尽量简短的描述图中物品，包含物品种类和颜色等";




/*    @PostMapping("/getBase64Code")
    @Operation(summary = "获取base64编码")
    public Result getBase64Code(String base64Code){
        String result=ModelUtil.getImageBase64ByUrl(base64Code);
        return Result.success(result);
    }*/



    @PostMapping("/insert")
    @Operation(summary = "调用大模型标签功能")
    public Result insertTag(@RequestParam String pic) throws IOException {
        //modelUtil.matchLost(pic,1854518347526504450L);

        return Result.success();
    }

    @GetMapping("/getAccessToken")
    @Operation(summary = "获取AccessToken")
    public Result getAccessToken(){

        return Result.success(modelUtil.getAuth());
    }

    @PostMapping("/getPicTag")
    @Operation(summary = "获取图片标签")
    public Result getPicTag(String picURL){

        return Result.success(modelUtil.imgCombination(picURL));
    }

/*    public String sample(){
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "");
        Request request = new Request.Builder()
                .url("https://aip.baidubce.com/oauth/2.0/token?client_id=&client_secret=&grant_type=client_credentials")
                .method("POST", body)
                .addHeader("Content-Type", "application/json")
                .addHeader("Accept", "application/json")
                .build();
        Response response = HTTP_CLIENT.newCall(request).execute();
        System.out.println(response.body().string());
    }*/




}
